package com.hmall.pay.web;

import com.hmall.common.dto.PageDTO;
import com.hmall.pay.pojo.ItemDoc;
import com.hmall.pay.pojo.RequestParams;
import com.hmall.pay.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private SearchService searchService;
    @GetMapping("/suggestion")
    public List<String> SearchSg(@RequestParam("key") String key){
        return searchService.getSuggestions(key);
    }


    @PostMapping("/filters")
    public Map<String, List<String>> getFilters(@RequestBody RequestParams requestParams) {
        return searchService.getFilters(requestParams);
    }

    @PostMapping("/list")
    public PageDTO<ItemDoc> search(@RequestBody RequestParams params){
        return searchService.search(params);
    }
//    @Autowired
//    private ItemClient itemClient;
////
//    @GetMapping
//    public void asd() {
//        PageDTO<Item> itemPageDTO = itemClient.GetList(1, 2);
//        System.out.println("itemPageDTO = " + itemPageDTO);
//    }

}
